/*
 * @author zei, QQ:77132995, email:kazeik@163.com
 * 2022/3/15 13:22
 * 类说明:
 */

import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/provider/currency_exchange_provider.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:finance_app/src/widgets/list_item/chart_account_open_balance_item.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

import '../router_gen/router_meta.dart';

class CurrencyExchange extends StatelessWidget {
  final String domesticCurrency;
  final String foreignCurrency;
  final String domesticCurrencyAmount;
  final String foreignCurrencyAmount;

  final ValueChanged<String> amountChange;

  CurrencyExchange(
      {Key key,
      @required this.domesticCurrency,
      @required this.foreignCurrency,
      @required this.domesticCurrencyAmount,
      @required this.foreignCurrencyAmount,
      this.amountChange})
      : assert(domesticCurrency != null),
        assert(foreignCurrency != null),
        assert(domesticCurrencyAmount != null),
        assert(foreignCurrencyAmount != null),
        super(key: key);

  @override
  Widget build(BuildContext context) => ListTile(
        title: Row(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            Container(
              margin: EdgeInsets.only(left: getDp(10),right: getDp(10),),
              child: Text(
                this.domesticCurrency,
                style: TextStyle(
                  color: aceBlackColor,
                  fontSize: getSp(16),
                  fontWeight: FontWeight.w700,
                ),
              ),
            ),
            Flexible(
              child: PrefixInputField(
                hardAmount: '$domesticCurrencyAmount',
                fontSize: 24,
                enabled:false,
                initValue: '$domesticCurrencyAmount',
              ),
            ),
            Container(
              margin: EdgeInsets.only(
                left: getDp(10),
                right: getDp(10),
              ),
              child: SvgPicture.asset(A.assetsImagesChange),
            ),
            Container(
              margin: EdgeInsets.only(
                left: getDp(5),
                right: getDp(10),
              ),
              child: Text(
                this.foreignCurrency,
                style: TextStyle(
                  color: aceBlackColor,
                  fontSize: getSp(16),
                  fontWeight: FontWeight.w700,
                ),
              ),
            ),
            Container(
              constraints: BoxConstraints(
                maxWidth: getDp(130),
              ),
              child: PrefixInputField(
                textAlign: TextAlign.left,
                fontSize: 24,
                initValue: "${this.foreignCurrencyAmount}",
                onUpdateValue: (str) => this.amountChange(str),
              ),
            )
          ],
        ),
      );
}
